/* $Header: err_init.c,v 2.2 01/10/02 10:26:56 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991, 1992           */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME:  err_init.c                                            */
/* ============                                                        */
/*                                                                     */
/* Author:  Lesley Freed                                               */
/*                                                                     */
/* MODULE PURPOSE:  To initialize non-fatal errrors, warnings and      */
/*                  not-ready status.                                  */
/*                                                                     */
/***********************************************************************/


/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>
#include <p_wkfile.h>
#include <wkfile.h>
#include <ramps.h>
#include <zone_config.h>
#include <zone_status.h>
#include <status.h>

#include <exception.h>
#include <err_handler.h>

/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/


/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/


/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/

/**************/
/* NOT READYS */
/**************/

/***********************************************************************/
/* FUNCTION:  ClearNotReadyEval                                        */
/* ========                                                            */
/*                                                                     */
/* PURPOSE:  To clear the not ready evaluated words.  This will give   */
/*           a mechanism to check that all of the readiness bits have  */
/*           been evaluated before we proceed to declare the state of  */
/*           readiness.                                                */
/*                                                                     */
/* RETURNED VALUE:  none                                               */
/*                                                                     */
/* GLOBALS USED:  Not_Ready_Eval_Word_1, Not_Ready_Core_Eval_Word_1    */
/*                Not_Ready_Ext_Eval_Word_1, Not_Ready_Det_Eval_Word_1 */
/*                                                                     */
/* CALLS:  none                                                        */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/***********************************************************************/

void ClearNotReadyEval ( void )
{
   EXCEPTION_WORDS *words;

   words = FIRST_EXCEPTION;

   while ( words <= LAST_NOT_READY )
   {
      words->eval = 0;
      words++;
   }

   /* Clear a flag for the ramp generator to set.  This will hold off */
   /* setting of the eval bits until after the ramp generator has     */
   /* updated its setpoints.                                          */
   Ramps_Executed = FALSE;
}


void ClearWarnings ( void )
{
   EXCEPTION_WORDS *words;

   words      = &Warning[0];

   while ( words <= &Warning[ WARNING_WORD_COUNT-1 ] )
   {
      words->status = 0;
      words->eval   = 0;
      words->glp    = 0;
      words++;
   }

   ClearMethodWarnings();
}

void ClearMethodWarnings ( void )
{
   EXCEPTION_WORDS *words;
   words      = &Method_Warning[0];

   while ( words <= &Method_Warning[ METHOD_WARNING_WORD_COUNT-1 ] )
   {
      words->status = 0;
      words->eval   = 0;
      words->glp    = 0;
      words++;
   }
}

void InitializeExceptions( void )
{
   EXCEPTION_WORDS *words;

   words = FIRST_EXCEPTION;

   while ( words <= LAST_EXCEPTION )
   {
      words->status = 0;
      words->eval   = 0;
      words->glp    = 0;
      words++;
   }
}

void ClearGlpWords( void )
{
   EXCEPTION_WORDS *words;

   words = FIRST_EXCEPTION;

   while ( words <= LAST_EXCEPTION )
   {
      words->glp    = 0;
      words++;
   }
}
